<?php

namespace App\Admin\Extensions\Tools\Price;

use Encore\Admin\Grid\Tools\BatchAction;

class ReleasePrice extends BatchAction
{
    protected $action;

    public function __construct($action = 1)
    {
        $this->action = $action;
    }

    public function script()
    {
        switch ($this->action){
            case 'up':
                $url = route('entity.pm.prices.up');
                break;
            case 'down':
                $url = route('entity.pm.prices.down');
                break;
            case 'publish':
                $url = route('entity.pm.prices.publish_one');
                break;
            case 'publishDown':
                $url = route('entity.pm.prices.publish_down_one');
                break;
            case 'inSale':
                $url = route('entity.pm.prices.in_sale');
                break;
            case 'stopSale':
                $url = route('entity.pm.prices.stop_sale');
                break;
        }
        return <<<EOT
$('{$this->getElementClass()}').on('click', function() {
       batchUpDownPublish('$url',selectedRows(),'$this->action')
});

EOT;

    }
}